// 加载状态的类库
import type { IStateCreateOption } from '../../../lib/types/type'
import { defineStore } from '../../../lib/main'

export type IPerson = {
  name: string;
  age: number;
  get getName(): string;
  get getAge(): number;
  addAge(n: number): void;
  addAge2(n: number): void;
}

// 默认是局部状态
export default () => {
  return defineStore('Person', {
    state: () => {
      return {
        name: '基础设置',
        age: 20
      }
    },
    getters: {
      getName() {
        return this.name + ' + 普通函数'
      },
      getAge: (state: any) => {
        return state.age + ' + 箭头函数'
      }

    },
    actions: {
      addAge(n = 1) {
        this.age += n

      },
      addAge2: (state: any, n = 1 ) => {
        state.age += 10 * n
      }
    },
    options: {
      isLog: false
    }
  })
}